<?php

use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Wire\AMQPTable;

require __DIR__ . '/../../vendor/autoload.php';

$config = require(__DIR__ . '/../config.php');
$connection = new AMQPStreamConnection(
    $config['host'],
    $config['port'],
    $config['user'],
    $config['password'],
    $config['vhost']
);

$channel = $connection->channel();

const DEAD_QUEUE = 'dead_queue';
$channel->basic_consume(DEAD_QUEUE, '', false, true, false, false, function($msg) {
    echo $msg->body . PHP_EOL;
});

while ($channel->is_open()) {
    $channel->wait();
}

$channel->close();
$connection->close();